package com.gjy.kafka.k10.admin;

import com.google.common.collect.Lists;
import org.apache.kafka.clients.admin.Admin;
import org.apache.kafka.clients.admin.AdminClientConfig;
import org.apache.kafka.clients.admin.CreateTopicsResult;
import org.apache.kafka.clients.admin.NewTopic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Properties;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-10-03 12:01:21
 */
public class AdminTopic {

    private static final Logger log = LoggerFactory.getLogger(AdminTopic.class);

    public static void main(String[] args) {
        Properties props = new Properties();
        props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.253.136:9092");
        Admin admin = Admin.create(props);

        CreateTopicsResult result = admin.createTopics(Lists.newArrayList(
                new NewTopic("java_topic_1", 1, (short) 1))
        );
        log.info("创建结果：{}", result.values());
        admin.close();
    }
}
